<template>
    <div class="nav">
        <router-link tag="div" :class="{now: item.name === getNow}" v-for="(item,i) in navList" :key="i" :to="item.to">
            <i class="iconfont" :class="'icon-nav-'+i"></i>
            {{item.name === getNow ? item.name: ''}}
        </router-link>
    </div>
</template>
<script>
  export default {
    name: 'now-nav',
    data: function () {
      return {
        navList: [
          {name: '账单', to: 'bill'},
          {name: '资产', to: 'asset'},
          {name: '设置', to: 'setting'},
        ]
      }
    },
    created: function () {}, // 创建时
    beforeMount: function () {}, // 挂载之前
    mounted: function () {}, // 挂载之后
    beforeUpdate: function () {}, // 数据更新时调用,在渲染之前
    updated: function () {}, // 数据更新后,渲染后调用(禁止)
    beforeDestroy: function () {}, // 实例销毁前调用,解绑中间层的数据传输
    destroyed: function () {}, // 实例销毁后调用
    computed: {
      getNow () {
        return this.$route.meta.now || '账单'
      }
    },
    methods: {} // 函数
  }
</script>
<style lang='scss'>
    .nav {
        box-sizing: border-box;
        border-top: 1px solid #f0f0f0;
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        > div {
            flex: 1;
            height: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            box-sizing: border-box;
            color: black;
            font-size: 12px;
            i {
                font-size: 30px;
                transition: font-size 0.2s;
            }
            &.now {
                color: #fa8f2f;
                i {
                    font-size: 24px;
                }
            }
        }
    }
</style>
